package com.opeartion.service.impl;

import com.opeartion.dao.StoreMapper;
import com.opeartion.pojo.CheckStatus;
import com.opeartion.pojo.Store;
import com.opeartion.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Component
@SuppressWarnings("all")
public class StoreServiceImpl implements StoreService {

    @Autowired
    private StoreMapper storeMapper;

    @Override
    public List<Store> getAllStore() {
        List<Store> storeAll = storeMapper.findStoreAll();
        return storeAll;
    }

    @Override
    public List<Store> findCategotry(String name) {
        return storeMapper.findByStoreTmtName(name);
    }

    @Override
    public List<Store> findStore(String storeld) {
        Map map = new HashMap();
        try {
            Integer.parseInt(storeld);
            map.put("storeld", storeld);
        }catch (Exception e){
            map.put("storename", storeld);
        }
        return storeMapper.findStoreAll(map);
    }

    @Override
    public void UpdateStoreId(Integer status, Integer id) {
        if (status==1){
            status = 2;
        }else if (status==2){
            status=1;
        }
        Map map = new HashMap();
        map.put("status",status);
        map.put("id",id);
        storeMapper.UpdateStoreId(map);
    }

    @Override
    public List<Store> checkStatus() {
        return storeMapper.checkStatus();
    }

    @Override
    public List<Store> findStatus(CheckStatus checkStatus) {
        System.out.println(checkStatus);
        Map map =new HashMap();
        map.put("id",checkStatus.getStoreld());
        map.put("storename",checkStatus.getStorename());
        map.put("tmt",checkStatus.getTmt());
        return storeMapper.checkStatus(map);
    }

    @Override
    public void UpdateStatus(int status,String describe, int storeld) {
        if (status==1)
        storeMapper.UpdateStatus(status,describe,storeld);
    }


}
